﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Modbus.Device;//引用Modbus库命名空间
namespace ModbusRTU_Master
{
    public partial class UserControl2 : UserControl
    {
        public UserControl2()
        {
            InitializeComponent();
        }

        private void UserControl2_Load(object sender, EventArgs e)
        {

        }

        private void button_Send_Click(object sender, EventArgs e)
        {
            //if (serialPort.IsOpen)
            //{ 
            
            //}

        }

        private void textBox_IGBT_Cur_gain_R_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.IGBT_Current_Gain;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }
        //无用方法
        private void textBox_IGBT_Cur_gain_R_KeyPress(object sender, KeyPressEventArgs e)
        {
            
            // 检查是否为数字或退格键（用于删除）
            if (!char.IsDigit(e.KeyChar) && e.KeyChar != (char)Keys.Back)
            {
                e.Handled = true; // 阻止非数字输入
                Form3 Window3 = new Form3();
                Window3.ShowDialog();
            }
        }

        private void textBox_Vdref_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.Vdref;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_RatePower_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.RatePower;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_Vdlvrt_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.Vdlvrt;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_Vdhvrt_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.Vdhvrt;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_InvT_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.InvT;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_Ucap_charge_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.Ucap_charge;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_Ucap_stop_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.Ucap_stop;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_Ucap_Dvr_quit_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.Ucap_Dvr_quit;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_OverUdcPeak_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.OverUdcPeak;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_OverUdcDly_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.OverUdcDly;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_UnderUdc_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.UnderUdc;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_UnderUdcDly_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.UnderUdcDly;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_IGBTOverIRms_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.IGBTOverIRms;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_IGBTOverIRmsDly_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.IGBTOverIRmsDly;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_IGBTOverURms_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.IGBTOverURms;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_IGBTOverURmsDly_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.IGBTOverURmsDly;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_IGBTFanLev_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.IGBTFanLev;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_IGBTFanErrLev_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.IGBTFanErrLev;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_SCRFanLev_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.SCRFanLev;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_SCRanErrLev_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.SCRanErrLev;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_ENVFanLev_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.ENVFanLev;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox__ENVFanErrLev_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.ENVFanErrLev;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_OverSysIRms_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.OverSysIRms;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_OverSysIRms_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox_OverSysIRmsDly_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.OverSysIRmsDly;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_OverIgbtIPeak_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.OverIgbtIPeak;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_OverIIgbtDly_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.OverIIgbtDly;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_IgbtFaultDly_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.IgbtFaultDly;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_HWIgbtFaultDly_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.HWIgbtFaultDly;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_OverIcapRms_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.OverIcapRms;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_OverIcapRmsDly_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.OverIcapRmsDly;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_OverFreqAC_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.OverFreqAC;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_UnderFreqAC_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.UnderFreqAC;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_OverUPake_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.OverUPake;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_OverUPakeDly_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.OverUPakeDly;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }

        private void textBox_SCR_num_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Form1.CurrentRegisterAddress = Form1.RegisterAddress.SCR_num;
            Form3 Window3 = new Form3();
            Window3.ShowDialog();
        }
    }
}
